﻿
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "ElementId.h"
#include "RuntimeId.h"

namespace gcmp
{
    class IDocument;
    class IGraphicsNode;
}

namespace Sample
{
    class IGraphicsNode_Wrapper;

    class GRepProbe
    {
    public:
        void Execute(bool isViewSpecific, gcmp::IDocument* pDoc, gcmp::ElementId elemId);
        static GRepProbe* Get() { return m_opGRepProbe.get(); };
        const bool IsValid() const;
    private:
        // 将GRep浏览器修改后的GRep设置给图元
        void UpdateGraphicsNodeToElement(IGraphicsNode_Wrapper* gNode_Wrapper);
        // 根据Element更新GRep探针浏览器和GRep浏览器
        void UpdateUI(gcmp::IDocument* pDoc, gcmp::ElementId id);
        GRepProbe();
    private:
        // 探针中目前图元的特性
        bool m_isDirectShape;
        bool m_isPGE;
        bool m_isViewSpecific;

    private:
        static gcmp::OwnerPtr<GRepProbe> m_opGRepProbe;
        gcmp::ElementId m_cached_id;
        gcmp::RuntimeId m_cached_docId;
    };
}

